function e(e, t, a) {
    return t in e ? Object.defineProperty(e, t, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = a, e;
}

function t(e) {
    var t = this, r = e.target.dataset.src, i = e.target.dataset.from;
    if (void 0 !== i && i.length > 0) {
        var n = o(t.data, i), s = [ r ];
        s = n && n.imageUrls ? n.imageUrls : a(n), wx.previewImage({
            current: r,
            urls: s
        });
    }
}

function a(e) {
    for (var t = [], r = 0; r < e.length; r++) {
        var i = e[r];
        if ("img" == i.tag) t.push(i.attr.src); else if (i.nodes) {
            var n = a(i.nodes);
            t = t.concat(n);
        }
    }
    return t;
}

function r(e) {
    var t = this, a = e.target.dataset.from, r = e.target.dataset.index;
    void 0 !== a && a.length > 0 && i(e, r, t, a);
}

function i(t, a, r, i) {
    var s, d = o(r.data, i);
    if (d) {
        var g = n(t.detail.width, t.detail.height, r, d), l = "" + i;
        if (d && d.nodes) {
            var u = !0, v = !1, h = void 0;
            try {
                for (var f, m = a.split(".")[Symbol.iterator](); !(u = (f = m.next()).done); u = !0) l += ".nodes[" + f.value + "]";
            } catch (e) {
                v = !0, h = e;
            } finally {
                try {
                    !u && m.return && m.return();
                } finally {
                    if (v) throw h;
                }
            }
        } else for (var c = a.split("."), w = 0; w < c.length; w++) l += 0 == w ? "[" + c[w] + "]" : ".nodes[" + c[w] + "]";
        var x = l + ".width", P = l + ".height";
        r.setData((s = {}, e(s, x, g.imageWidth), e(s, P, g.imageheight), s));
    }
}

function n(e, t, a, r) {
    var i = 0, n = 0, o = 0, s = {}, l = r && r.view ? r.view.imagePadding : 0;
    return i = d - 2 * l, g, e > i ? (o = (n = i) * t / e, s.imageWidth = n, s.imageheight = o) : (s.imageWidth = e, 
    s.imageheight = t), s;
}

function o(e, t) {
    t = t.split(".");
    for (var a = 0; a < t.length; a++) e = e[t[a]];
    return e;
}

var s = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("./html2json.js")), d = 0, g = 0;

wx.getSystemInfo({
    success: function(e) {
        d = e.windowWidth, g = e.windowHeight;
    }
}), module.exports = {
    wxParse: function() {
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "wxParseData", a = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "html", i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : '<div class="color:red;">数据不能为空</div>', n = arguments[3], o = arguments[4], d = n, g = {};
        if ("html" == a && (g = s.default.html2json(i, e)), g.view = {}, g.view.imagePadding = 0, 
        void 0 !== o && (g.view.imagePadding = o), d.wxParseImgTap = t, d.wxParseImgLoad = r, 
        e == getApp().getWxParseOldPattern()) return d.wxParseImgTap = function() {}, g.nodes;
        var l = {};
        return l[e] = g, d.setData(l), d.wxParseImgTap = t, g.nodes;
    },
    wxParseTemArray: function(e, t, a, r) {
        for (var i = [], n = r.data, o = null, s = 0; s < a; s++) {
            var d = n[t + s].nodes;
            i.push(d);
        }
        e = e || "wxParseTemArray", (o = JSON.parse('{"' + e + '":""}'))[e] = i, r.setData(o);
    },
    emojisInit: function() {
        var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "/wxParse/emojis/", a = arguments[2];
        s.default.emojisInit(e, t, a);
    }
};